fe226625900f253edcea11329468e0eca099e761,src/java/org/orbeon/oxf/util/NetUtils.java,NetUtils,decodeQueryString,#String#boolean#,206
Before Change
*/
public static Map decodeQueryString(String query, boolean acceptAmp) {
final Map parameters = new HashMap();
if (query == null)
return parameters;
final StringTokenizer st = new StringTokenizer(query, "&");
try {
while (st.hasMoreTokens()) {
String token = st.nextToken();
// Check if & is also supported as delimiter
if (acceptAmp && token.startsWith("amp;"))
token = token.substring(4);
final int equalIndex = token.indexOf('=');
if (equalIndex == -1)
throw new OXFException("Malformed URL: " + query);
final String name = URLDecoder.decode(token.substring(0, equalIndex), NetUtils.DEFAULT_URL_ENCODING);
final String value = URLDecoder.decode(token.substring(equalIndex + 1), NetUtils.DEFAULT_URL_ENCODING);
NetUtils.addValueToStringArrayMap(parameters, name, value);
}
} catch (UnsupportedEncodingException e) {
After Change
final java.util.Map ret = new java.util.TreeMap();
if ( qry != null ) {
final Matcher m = accptAmp ? PATTERN_AMP.matcher( qry ) : PATTERN_NO_AMP.matcher( qry );
int mtchEnd = 0;
while ( m.find() )
{
if ( m.start() != mtchEnd ) {
// We have detected something like a=b=c=d. That is we noticed that the last
// match ended on 'b' and that this match starts on 'c'. Since we skipped
// something there must be a problem.
throw new OXFException( "Malformed URL: " + qry );
}
mtchEnd = m.end();
try {
// Group 0 is the whole match, e.g. a=b, while group 1 is the first group
// denoted ( with parens ) in the expression. Hence we start with group 1.
String nam = m.group( 1 );
nam = URLDecoder.decode( nam, NetUtils.DEFAULT_URL_ENCODING );
String val = m.group( 2 );
val= URLDecoder.decode( val, NetUtils.DEFAULT_URL_ENCODING );
NetUtils.addValueToStringArrayMap( ret, nam, val );
} catch ( final java.io.UnsupportedEncodingException e ) {